Skip to content
This repository was archived by the owner on Jul 7, 2019. It is now read-only.

Add a "Tag" model for event classification (Issue #161). #176

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

dmgardiner25
Copy link

@dmgardiner25 dmgardiner25 commented Mar 27, 2018

Closes: #161

In order to classify an event (for positioning on the home page or if users need to pay for it) a "Tag" model was created and linked to the "Event" model through a ManyToManyField. The tags are displayed as a CheckboxSelectMultiple widget to make it user-friendly.

#: The name of the tag that is displayed on the event creation form; represented
#: as a CharField.
display_name = models.CharField(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have unique=True, we don't want two tags have the same display name

)

#: Unique id of the tag; represented as an IntegerField.
id = models.IntegerField(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I was thinking for this id was another CharField which has an unchanging name that the creator of this Tag creates. This makes things look better from the API perspective when requesting event data.

Changes what is displayed for each tag on the event creation
form (without this it shows 'Tag object (id)').

:return: String containing the name of the tag.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be :returns:. Also, The text should probably be "The display name of the tag". You don't need to mention the type because it is stated in the statement below.

Copy link
Author

@dmgardiner25 dmgardiner25 Mar 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other two functions just say :return: as well so I'll go ahead and change those too.

form (without this it shows 'Tag object (id)').

:return: String containing the name of the tag.
:rtype: string.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No period, should be str.


#: If the tag should be diplayed on the event creation form; represented as a
#: BooleanField.
display = models.BooleanField(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if I necessarily agree with the name of this being display. The concept behind this was that if this field is true, the user can no longer add this tag to the event nor can it be seen on events that have already used this tag. This first part of this can be solved with https://stackoverflow.com/questions/3010489/how-do-i-filter-values-in-a-django-form-using-modelform#3013509 and a custom function on this model which is something like is_enabled(). I believe the name should be something like is_disabled. What do you think?

@@ -47,6 +47,46 @@ def get_path_for_flier(instance, filename):
)


class Tag(models.Model):
"""
Class used for adding classification tags on events.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would avoid using Class here and rephrase this docstring.


def __str__(self):
"""
Changes what is displayed for each tag on the event creation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know that you necessarily need to put this description on this function. The __str__ attribute is a Python standard attribute which returns this object whenever str() is called on it. Moreover, these descriptions should avoid addressing django-specific projects and be specific to the function or return itself.

Class used for adding classification tags on events.
"""

#: The name of the tag that is displayed on the event creation form; represented
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not exclusively be what it will be used for. It will be used anytime that we display the Tag. Rephrase to make more generic.

#: as a CharField.
display_name = models.CharField(
verbose_name=_('Event Tag'),
help_text=_('Different categories for the event.'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This help text is not really descriptive as to what it does. Should be something along the lines of The name of the Tag that will be displayed to users

@kevinschoonover
Copy link
Contributor

Two more generic comments is that the automatic tests of your code has failed and the content of your PR should say (below your paragraph):

Closes: #161

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants